package com.googlecode.spreadit.handler;

import static com.googlecode.spreadit.handler.SpreadRuleHandler.EXTRAS_CONTENT_KEY;
import static com.googlecode.spreadit.handler.SpreadRuleHandler.MESSAGE_BUNDLE_KEY;
import static com.googlecode.spreadit.handler.SpreadRuleHandler.RECEIVER_BUNDLE_KEY;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.AndroidRuntimeException;

import com.googlecode.spreadit.bean.Message;
import com.googlecode.spreadit.bean.SpreadReceiver;

/**
 * This handler {@link Activity} receives application-internal
 * {@value #HANDLER_ID} actions. Upon these actions a WhatsApp message is sent.
 * The content and recipients of the e-mail are given in the {@link Intent}'s
 * extras.
 * 
 * TODO: This handler is currently just a mock implementation and not
 * implemented yet.
 * 
 * @see OutgoingSmsHandler
 * @see OutgoingEmailHandler
 * 
 * @author Markus L. Dechert (markus.dechert@googlemail.com)
 */
public class OutgoingWhatsAppHandler extends Activity {

	public static final String HANDLER_ID = "com.googlecode.spreadit.ACTION_HANDLE_WHATS_APP";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onResume() {

		super.onResume();

		if (getIntent() != null && getIntent().getExtras() != null) {

			final Bundle extraBundle = getIntent().getExtras();

			final Message message = (Message) extraBundle.getBundle(
					MESSAGE_BUNDLE_KEY).getSerializable(EXTRAS_CONTENT_KEY);
			final SpreadReceiver receiver = (SpreadReceiver) extraBundle
					.getBundle(RECEIVER_BUNDLE_KEY).getSerializable(
							EXTRAS_CONTENT_KEY);

			throw new AndroidRuntimeException(this.getClass().getSimpleName()
					+ " is not implemented yet!");
		}
		finish();
	}

}
